package com.losalpes.security;

import com.losalpes.persistence.entity.TipoUsuario;
import com.losalpes.persistence.entity.Usuario;
import javax.ejb.EJB;

/**
 *
 * @author Camilo Alvarez
 */
public class SecurityBean {

    @EJB
    private ISecurityService securityService;
    private String username;
    private String pwd;
    private Boolean isLogged=Boolean.FALSE;

    public SecurityBean() {
        //securityService = new SecurityServiceMock();
    }

    public String login() {
        Usuario user = securityService.login(username, pwd);
        this.setIsLogged(Boolean.TRUE);
        if (user.getTipoUsuario() == TipoUsuario.ADMINISTRADOR) {
            return "administrador";
        } else {
            return "cliente";
        }
    }

    public String login2() {
        if (this.username.equals("")) 
            return "sinIdentificar";
        else
            return "pagar";
    }


    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public boolean isIsLogged() {
        return isLogged;
    }

    public void setIsLogged(boolean isLogged) {
        this.isLogged = isLogged;
    }

    public String goToClientes() {
        return "clientes";
    }

    public String goToCatalogo() {
        return "catalogo";
    }

    public String goToReportePorFecha() {
        return "reportePorFecha";
    }

    public String goToReporteMasVendido() {
        return "reporteMasVendido";
    }

    public String goToMenuAdmin() {
        return "menuadmin";
    }

    public String goToMenuLogin() {
        return "login";
    }
    
    public String goToReportePorCliente() {
        return "reportePorCliente";
    }
}
